package com.sztz.mapstruct.R映射List;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * CarMapper
 *
 * @author yyf
 * @Mapper(componentModel = "spring")
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);


    /**
     * 简单映射
     *
     * @param cars
     * @return CarDTO
     */
    @Mapping(source = "owner", target = "ownerName")
    CarDTO toDto(Car cars);

    /**
     * 映射集合如果有不同名属性，需要指定单个对象的映射
     *
     * @param cars
     * @return CarDto
     */
    List<CarDTO> toDto(List<Car> cars);
}
